//
//  MyEvaluationViewTableViewCell.m
//  DJS
//
//  Created by 浪尖渝力 on 2018/2/8.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "MyEvaluationViewTableViewCell.h"

@implementation MyEvaluationViewTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(CGFloat)creatView{
    self.backgroundColor=_LightGrey;
    
    UIView *beiJinView=[UIView new];
    [self addSubview:beiJinView];
    [beiJinView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(5);
        make.right.mas_equalTo(-5);
        make.bottom.mas_equalTo(0);
        make.top.mas_equalTo(10);
    }];
    beiJinView.backgroundColor=[UIColor whiteColor];
    beiJinView.layer.cornerRadius=5;
    
    UIImageView *iamgeView=[UIImageView new];
    [beiJinView addSubview:iamgeView];
    [iamgeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(10);
        make.width.height.mas_equalTo(60);
    }];
    iamgeView.layer.cornerRadius=30;
    iamgeView.layer.masksToBounds=YES;
    NSString *news_cover=[_dic objectForKey:@"user_icon"];
    news_cover=[NSString stringWithFormat:@"%@%@",_addressUrl,news_cover];
    [iamgeView sd_setImageWithURL:[NSURL URLWithString:news_cover]];
    
    NSString *phoneStr=[_dic objectForKey:@"user_nickname"];
    UILabel *label=[UILabel new];
    [beiJinView addSubview:label];
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(iamgeView.mas_right).mas_equalTo(6);
        make.top.mas_equalTo(iamgeView);
        make.right.mas_equalTo(-120);
    }];
    label.text=phoneStr;
    label.textColor=ColorWithRGB(49, 49, 49);
    label.font=[UIFont systemFontOfSize:17];
    
    NSString *time=[_dic objectForKey:@"evaluate_time_text"];
    UILabel *timeLabel=[UILabel new];
    [beiJinView addSubview:timeLabel];
    [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(label);
        make.bottom.mas_equalTo(iamgeView);
    }];
    timeLabel.text=time;
    timeLabel.font=[UIFont systemFontOfSize:14];
    timeLabel.textColor=ColorWithRGB(149, 149, 149);

    NSString *evaluate_content=[_dic objectForKey:@"evaluate_content"];
    CGSize size=[ZQTools getNSStringSize:evaluate_content andViewWight:_mainW-40 andFont:17];

    UILabel *contLable=[UILabel new];
    [beiJinView addSubview:contLable];
    [contLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(iamgeView);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(iamgeView.mas_bottom).mas_equalTo(20);
        make.height.mas_equalTo(size.height);
    }];
    contLable.numberOfLines=0;
    contLable.textColor=ColorWithRGB(79, 79, 79);
    contLable.text=[_dic objectForKey:@"evaluate_content"];
    contLable.font=[UIFont systemFontOfSize:17];
    
    UIView *xianView=[UIView new];
    [beiJinView addSubview:xianView];
    [xianView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.right.mas_equalTo(-10);
        make.top.mas_equalTo(contLable.mas_bottom).mas_equalTo(20);
        make.height.mas_equalTo(1);
    }];
    xianView.backgroundColor=_LightGrey;
    
    
    UILabel *pingFen=[UILabel new];
    [beiJinView addSubview:pingFen];
    [pingFen mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(xianView.mas_bottom).mas_equalTo(20);
        make.left.mas_equalTo(10);
    }];
    pingFen.text=@"评分:";
    pingFen.textColor=ColorWithRGB(149, 149, 149);
    pingFen.font=[UIFont systemFontOfSize:16];
    
    NSNumber *evaluate_score=[_dic objectForKey:@"evaluate_score"];
    int typeNum2=evaluate_score.doubleValue*10;
    int typeNum=typeNum2%10;
    int index=evaluate_score.floatValue;
    
    
    for (int i=0; i<5; i++) {
        UIImageView *xingImage=[UIImageView new];
        [beiJinView addSubview:xingImage];
        [xingImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(80+25*i);
            make.height.width.mas_equalTo(20);
            make.centerY.mas_equalTo(pingFen);
        }];
        
        if (typeNum>0) {
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
            if (i==index) {
                xingImage.image=[UIImage imageNamed:@"评分3"];
            }
            if (i>index) {
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
        }
        else{
            if (i<index) {
                xingImage.image=[UIImage imageNamed:@"评分2"];
            }
            else{
                xingImage.image=[UIImage imageNamed:@"评分1"];
            }
        }

    }
    
    
    return 180+size.height;
}

@end
